﻿namespace LeetCodeProject._0001_1000._001_100._71_80._071;

public class Solution
{
    public string SimplifyPath(string path)
    {
        var parts = path.Split('/');
        var list = new List<string>();
        foreach (var part in parts)
        {
            switch (part)
            {
                case "":
                case ".":
                    break;
                case "..":
                    if (list.Count > 0)
                    {
                        list.RemoveAt(list.Count - 1);
                    }

                    break;
                default:
                    list.Add(part);
                    break;
            }
        }

        return "/" + string.Join("/", list);
    }
}